import java.util.Arrays;

public class LC {
    public static void quickSort(int[] arr,int L,int R){
        if(L>R) {
            return;
        }
        int left=L;
        int right=R;
        int pivot=arr[left];
        while(left<right) {
            while(left<right && arr[right]>=pivot) {
                right--;
            }
            if(left<right) {
                arr[left++]=arr[right];
            }
            while(left<right && arr[left]<=pivot) {
                left++;
            }
            if(left<right) {
                arr[right--]=arr[left];
            }
            if(left==right) {
                arr[left]=pivot;
            }
        }
        quickSort(arr,L+1,R);
        quickSort(arr,L,R-1);
    }


    public static void main(String[] args){
        int[] arr={19,97,9,17,1,8};
        quickSort(arr,0, arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
}
//class Solution {
//    public int quicksort;
//    public int findKthLargest(int[] nums, int k) {
//        quicksort(nums,0,nums.length-1);
//    }
//}